package dao.ebean;

import com.avaje.ebean.Ebean;
import dao.common.ShopRepository;
import models.Shop;
import models.ShopOwner;

public class ShopRepositoryImpl implements ShopRepository {
    public long add(Shop shop) {
        Ebean.save(shop);
        return shop.id;
    }

    public Shop getById(long id) {
        return Ebean.find(Shop.class, id);
    }

    public void attachOwnerToShop(long shopId, ShopOwner owner) {
        Shop shop = getById(shopId);
        //shop.owners.add(owner);
        //Ebean.saveManyToManyAssociations(shop,"owners");
        shop.alias = "newalias";
        Ebean.save(shop);
    }
}
